//
// Created by Tan Ke on 2023/11/26.
//

#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int maxNumberOfBalloons(char* text)
{
    int array[26] = {0};
    int cnt = 0;

    for (int i = 0; i < 26; i ++) {
        array[i] = 0;
    }

    for (int i = 0; i < strlen(text); i ++) {
        array[text[i] - 'a'] += 1;
    }

    while (1) {
        if (array['b' - 'a'] > 0 && array['a' - 'a'] > 0 &&
            array['l' - 'a'] > 1 && array['o' - 'a'] > 1 &&
            array['n' - 'a'] > 0) {
            array['b' - 'a'] -= 1;
            array['a' - 'a'] -= 1;
            array['l' - 'a'] -= 2;
            array['o' - 'a'] -= 2;
            array['n' - 'a'] -= 1;
            cnt += 1;
        } else {
            break;
        }
    }

    return cnt;
}


int main(void)
{
    const char *s = "loonbalxballpoon";
    printf("%d\n", maxNumberOfBalloons((char*)s));

    return 0;
}
